#ifndef __CZF_TICKER_CONTENT_INTERFACE_H__
#define __CZF_TICKER_CONTENT_INTERFACE_H__

/* 
 * News item is store in the structure NewsItem, with text,
 *  background color and foreground color.
 */
typedef struct tagNewsItem
{
	char*		text;
	COLORREF	bkgrd;
	COLORREF	fore;
} NewsItem;

#define TICK_INTERVAL 5000 // 5 seconds

/*
 * The container will call GetNextNewsItem to get the content. And
 *  ReleaseNewsItem is called to release the storage.
 *
 * Note that the container might have several providers, say, PVDR1, PVDR2 and PVDR3.
 *  Container uses round robin scheme. First it repeatedly calls PVDR1->GetNextNewsItem, 
 *  when PVDR1 returns NULL. It starts to call PV until a NULL is restured.
 * So, IMPORTANT, it is mandatory for provider to return a NULL at the end of each round.
 * 
 * IMPORTANT, user need to copy NewItem and it's content, instead of using the returned pointer.
 *
 * Tick is a "clock tick", which will be called for every 5 seconds. this can be used 
 *  for updating from websites. It's better do the updating after provider returns NULL
 *  in GetnextNewsItem
 * 
 * Provider is associated with a Web URL, container asks provider for the URL when
 *  user needs detailed information.
 * Container first calls GetURLSize, then GetURL.
 */
class INewsContentProvider
{
public:
	virtual void GetNextNewsItem(NewsItem** ppItem) = 0;
	virtual void Tick() = 0;
	virtual size_t GetURLSize() = 0;
	// GetURL, on success returns 0, otherwise -1. 
	virtual int GetURL(char* url_buf, size_t bufsize)= 0;
};

/*
 * This is intented for using in a DLL. Call LoadLibrary to load the DLL in at runtime.
 *  Using GetProcAddress to get the function entry for CreateProvider and ReleaseProvider.
 *
 * Release Provider must be called before FreeLibrary.
 */

typedef INewsContentProvider* CreateFunc();
typedef void ReleaseFunc(INewsContentProvider* pvdr);


extern "C" {
__declspec( dllexport ) INewsContentProvider* CreateProvider();
__declspec( dllexport ) void ReleaseProvider(INewsContentProvider* pvdr);
}

#endif /* __CZF_TICKER_CONTENT_INTERFACE_H__ */